package com.antoco.controlcenter.base;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.BatteryManager;
import com.antoco.controlcenter.iface.IBatteryListener;

public class PowerReceiver extends BroadcastReceiver {

    private static final String TAG = PowerReceiver.class.getSimpleName();
    private IBatteryListener iBatteryListener;

    public PowerReceiver(IBatteryListener iBatteryListener) {
        this.iBatteryListener = iBatteryListener;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
        iBatteryListener.onChangeBattery(level);
    }

}
